import { Radio, Flex } from 'antd';

export interface JudgmentProps {
  answer?: boolean;
  state: 'QUESTYPE' | 'WRITE' | 'READ' | 'PREVIEW' | 'TODO'
  onAnswerChange?: (answer: boolean) => void;
}

function Judgment(props: JudgmentProps) {
  let { answer = false, state = 'QUESTYPE',  onAnswerChange = () => { } } = props;

  return (
    <div>
      <Radio.Group
        disabled={['READ', 'PREVIEW'].includes(state)}
        onChange={(e) => {
          onAnswerChange(e.target.value);
        }}
        value={answer}
      >
        <Flex gap={'5px'}>
          <Radio value={true} disabled={[ 'READ', 'PREVIEW'].includes(state)}>正确</Radio>
          <Radio value={false} disabled={[ 'READ', 'PREVIEW'].includes(state)}>错误</Radio>
        </Flex>
      </Radio.Group>
    </div>
  );
}

export default Judgment;
